package com.hos.net.req.sys;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.hos.net.req.BaseReq;
import com.hos.net.res.MsgHint;

/**
 * 重置密码
 * Created by guom on 2018/10/23.
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class PwdRestReq extends BaseReq {
    public String phone;
    //1: 系统注册 2：系统找回密码
    public String type;
    public String code;
    public String pwd;
    @JsonIgnore
    public String hint;

    // (false 检验失败)
    @JsonIgnore
    public boolean isVerifyParameter() {
        if (phone == null || phone.equals("")) {
            hint = new MsgHint("手机号不能为空").toJson();
            return false;
        }
        if (type == null || type.equals("")) {
            hint = new MsgHint("验证码类型不能为空").toJson();
            return false;
        }
        if (service.contains("sys") && !"2".equals(type)) {
            hint = new MsgHint("验证码类型错误").toJson();
            return false;
        }
        if (code == null || code.equals("")) {
            hint = new MsgHint("验证码不能为空").toJson();
            return false;
        }
        if (pwd == null || pwd.length() < 6 || pwd.length() > 18) {
            hint = new MsgHint("新密码格式不正确").toJson();
            return false;
        }
        return true;
    }
}
